package com.ldzy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ldzy.dao.MedicineMapper;
import com.ldzy.pojo.Medicine;
import com.ldzy.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MedicineServiceImpl implements MedicineService {
    @Autowired
    MedicineMapper medicineMapper;
    @Override
    public Page<Medicine> search(Integer pageNum, Integer pageSize,Medicine m) {
        PageHelper.startPage(pageNum,pageSize);//设置分页插件的参数
        Page<Medicine> medicines=medicineMapper.search(m);//启动dao的分页查询对数据执行查询
        return medicines;
    }

    @Override
    public int deleteMd(Integer mid) {
       return medicineMapper.deleteMd(mid);
    }

    @Override
    public Page<Medicine> all(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);//设置分页插件的参数
        Page<Medicine> medicines=medicineMapper.all();
        return medicines;
    }

    @Override
    public Medicine get(int id) {
        return medicineMapper.get(id);
    }

    @Override
    public void updateById(Medicine medicine) {
        medicineMapper.updateById(medicine);
    }

    @Override
    public int addMedicine(Medicine medicine) {
        return medicineMapper.addMedicine(medicine);
    }
}
